import './assets/main.css'
import { createApp } from 'vue/dist/vue.esm-bundler'
import VxeUIAll from 'vxe-pc-ui'
import 'vxe-pc-ui/lib/style.css'
import VxeUITable from 'vxe-table'
import 'vxe-table/lib/style.css'

// 全局设置
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
  faQrcode,
  faExchangeAlt,
  faUserSlash,
  faBed,
  faArrowsAltH,
  faSignOutAlt,
  faSignInAlt,
} from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'

library.add(faQrcode, faExchangeAlt, faUserSlash, faBed, faArrowsAltH, faSignOutAlt, faSignInAlt)

const app = createApp(App)

app.component('font-awesome-icon', FontAwesomeIcon)
app.use(createPinia())
app.use(router)
app.use(ElementPlus)
app.use(VxeUIAll)
app.use(VxeUITable) // VxeUITable

// 初始化主题并强制更新
const initTheme = () => {
  const theme = localStorage.getItem('theme') || 'default'
  document.documentElement.className = theme
  // 强制所有组件更新
  window.dispatchEvent(new CustomEvent('theme-init', { detail: theme }))
}
initTheme()

app.mount('#app')
